package com.example.demo.security.userdetails;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @author 叮当猫的百宝箱
 * @since 1.0
 */
@Data
public class ManagerUserDetails implements UserDetails, Serializable {

    private static final long serialVersionUID = -1104970159158219749L;

    private Long id;
    private String username;
    private String password;
    private Integer enable;
    private List<GrantedAuthority> authorities;

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enable != null && enable == 1;
    }
}
